{{ header }}{{ column_left }} 
<div id="content"><div class="container-fluid">
	<div class="page-header">
	    <h1>Custom Module</h1>
	    <ul class="breadcrumb">
		     {% for breadcrumb in breadcrumbs %} 
		      <li><a href="{{ breadcrumb['href'] }}">{{ breadcrumb['text'] }}</a></li>
		      {% endfor %} 
	    </ul>
	  </div>
	  
	  <script type="text/javascript" src="view/javascript/summernote/summernote.js"></script>
	  <link href="view/javascript/summernote/summernote.css" rel="stylesheet" />
		<!-- Disabled by Power Image Manager. Moved in the footer;  <script type="text/javascript" src="view/javascript/summernote/opencart.js"></script> -->
	  
    <link href='https://fonts.googleapis.com/css?family=Poppins:700,600,500,400,300' rel='stylesheet' type='text/css'>
    
	<script type="text/javascript">
	$.fn.tabs = function() {
		var selector = this;
		
		this.each(function() {
			var obj = $(this); 
			
			$(obj.attr('href')).hide();
			
			$(obj).click(function() {
				$(selector).removeClass('selected');
				
				$(selector).each(function(i, element) {
					$($(element).attr('href')).hide();
				});
				
				$(this).addClass('selected');
				
				$($(this).attr('href')).show();
				
				return false;
			});
		});
	
		$(this).show();
		
		$(this).first().click();
	};
	</script>

	{% if (error_warning) %} 
		<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_warning }} 
		  <button type="button" class="close" data-dismiss="alert">&times;</button>
		</div>
	{% elseif (success) %} 
		<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> {{ success }} 
			<button type="button" class="close" data-dismiss="alert">&times;</button>
		</div>
	{% endif %} 
	
	<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form">
		<div class="set-size" id="custom_module">
			<div class="content">
				<div>
					<div class="tabs clearfix">
						<!-- Tabs module -->
						<div id="tabs" class="htabs main-tabs">
							{% set module_row = 1 %} 
							{% for module in modules %} 
							<a href="#tab-module-{{ module_row }}" id="module-{{ module_row }}">Module {{ module_row }} &nbsp;<img src="view/image/module_template/delete-slider.png"  alt="" onclick="$('.vtabs a:first').trigger('click'); $('#module-{{ module_row }}').remove(); $('#tab-module-{{ module_row }}').remove(); return false;" /></a>
							{% set module_row = module_row + 1 %} 
							{% endfor %} 
                            <span id="module-add" onclick="addModule();"><img src="view/image/module_template/add.png" alt="" />Add<br> Module</span>
						</div>
						
						{% set module_row = 1 %} 
						{% for module in modules %} 
						<div id="tab-module-{{ module_row }}" class="tab-content">
							<table class="form" style="margin-bottom:10px">
							  <tr>
							    <td style="border:none;padding-top:7px">Type:</td>
							    <td style="border:none;padding-top:7px"><select name="custom_module_module[{{ module_row }}][type]" class="select-type" id="{{ module_row }}">
							    	{% if (1 == module['type']) %} 
							    	<option value="1" selected="selected">Block</option>
							    	{% else %} 
							    	<option value="1">Block</option>
							    	{% endif %} 
							    	{% if (2 == module['type']) %} 
							    	<option value="2" selected="selected">HTML</option>
							    	{% else %} 
							    	<option value="2">HTML</option>
							    	{% endif %} 
							      </select></td>
							  </tr>
							</table>
							<div id="language-{{ module_row }}" class="htabs">
							  {% for language in languages %} 
							  <a href="#tab-language-{{ module_row }}-{{ language['language_id'] }}"><img src="language/{{ language['code'] }}/{{ language['code'] }}.png" title="{{ language['name'] }}" /> {{ language['name'] }}</a>
							  {% endfor %} 
							</div>
							{% for language in languages %} 
							<div id="tab-language-{{ module_row }}-{{ language['language_id'] }}">
							  <div class="block{{ module_row }}" {% if (2 == module['type']) %} {{ 'style="display:none"' }} {% endif %}>
								  <table class="form">
								    <tr>
								      <td>Block heading:</td>
								      <td><input type="text" value="{{ module['block_heading'][language['language_id']] is defined ? module['block_heading'][language['language_id']] : '' }}" name="custom_module_module[{{ module_row }}][block_heading][{{ language['language_id'] }}]" style="width:250px"></td>
								    </tr>
								    <tr>
								      <td>Block content:</td>
								      <td><textarea name="custom_module_module[{{ module_row }}][block_content][{{ language['language_id'] }}]" id="block-content-{{ module_row }}-{{ language['language_id'] }}" data-toggle="summernote">{{ module['block_content'][language['language_id']] is defined ? module['block_content'][language['language_id']] : '' }}</textarea></td>
								    </tr>
								  </table>	
							  </div>
							  <div class="html{{ module_row }}" {% if (2 != module['type']) %} {{ 'style="display:none"' }} {% endif %}>
								  <table class="form">
								    <tr>
								      <td>HTML:</td>
								      <td><textarea name="custom_module_module[{{ module_row }}][html][{{ language['language_id'] }}]" class="html">{{ module['html'][language['language_id']] is defined ? module['html'][language['language_id']] : '' }}</textarea></td>
								    </tr>
								  </table>
							  </div>
							</div>
							{% endfor %} 
							<table class="form">
							  <tr>
							    <td>Layout:</td>
							    <td><select name="custom_module_module[{{ module_row }}][layout_id]">
							    	{% if (99999 == module['layout_id']) %} 
							    	<option value="99999" selected="selected">All pages</option>
							    	{% else %} 
							    	<option value="99999">All pages</option>
							    	{% endif %} 
							    	
							    	{% for store in stores %} 
							    	     {% if ('99999' ~ store['store_id'] == module['layout_id']) %} 
							    	     <option value="99999{{ store['store_id'] }}" selected="selected">All pages - Store {{ store['name'] }}</option>
							    	     {% else %} 
							    	     <option value="99999{{ store['store_id'] }}">All pages - Store {{ store['name'] }}</option>
							    	     {% endif %} 
							    	{% endfor %} 
							    	
							        {% for layout in layouts %} 
							        {% if (layout['layout_id'] == module['layout_id']) %} 
							        <option value="{{ layout['layout_id'] }}" selected="selected">{{ layout['name'] }}</option>
							        {% else %} 
							        <option value="{{ layout['layout_id'] }}">{{ layout['name'] }}</option>
							        {% endif %} 
							        {% endfor %} 
							      </select></td>
							  </tr>
							  <tr>
							    <td>Position:</td>
							    <td><select name="custom_module_module[{{ module_row }}][position]">
						     	{% if (module['position'] == 'header_notice') %} 
						     	<option value="header_notice" selected="selected">Header notice</option>
						     	{% else %} 
						     	<option value="header_notice">Header notice</option>
						     	{% endif %} 
						     	{% if (module['position'] == 'top_block') %} 
						     	<option value="top_block" selected="selected">Top block</option>
						     	{% else %} 
						     	<option value="top_block">Top block</option>
						     	{% endif %} 
							    	{% if (module['position'] == 'menu') %} 
							    	<option value="menu" selected="selected">Menu</option>
							    	{% else %} 
							    	<option value="menu">Menu</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'menu2') %} 
							    	<option value="menu2" selected="selected">Menu2</option>
							    	{% else %} 
							    	<option value="menu2">Menu2</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'slideshow') %} 
							    	<option value="slideshow" selected="selected">Slideshow</option>
							    	{% else %} 
							    	<option value="slideshow">Slideshow</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'preface_left') %} 
							    	<option value="preface_left" selected="selected">Preface left</option>
							    	{% else %} 
							    	<option value="preface_left">Preface left</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'preface_right') %} 
							    	<option value="preface_right" selected="selected">Preface right</option>
							    	{% else %} 
							    	<option value="preface_right">Preface right</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'preface_fullwidth') %} 
							    	<option value="preface_fullwidth" selected="selected">Preface fullwidth</option>
							    	{% else %} 
							    	<option value="preface_fullwidth">Preface fullwidth</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'column_left') %} 
							    	<option value="column_left" selected="selected">Column left</option>
							    	{% else %} 
							    	<option value="column_left">Column left</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'content_big_column') %} 
							    	<option value="content_big_column" selected="selected">Content big column</option>
							    	{% else %} 
							    	<option value="content_big_column">Content big column</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'content_top') %} 
							    	<option value="content_top" selected="selected">Content top</option>
							    	{% else %} 
							    	<option value="content_top">Content top</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'column_right') %} 
							    	<option value="column_right" selected="selected">Column right</option>
							    	{% else %} 
							    	<option value="column_right">Column right</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'content_bottom') %} 
							    	<option value="content_bottom" selected="selected">Content bottom</option>
							    	{% else %} 
							    	<option value="content_bottom">Content bottom</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'customfooter_top') %} 
							    	<option value="customfooter_top" selected="selected">CustomFooter Top</option>
							    	{% else %} 
							    	<option value="customfooter_top">CustomFooter Top</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'customfooter_bottom') %} 
							    	<option value="customfooter_bottom" selected="selected">CustomFooter Bottom</option>
							    	{% else %} 
							    	<option value="customfooter_bottom">CustomFooter Bottom</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'footer_top') %} 
							    	<option value="footer_top" selected="selected">Footer top</option>
							    	{% else %} 
							    	<option value="footer_top">Footer top</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'footer_left') %} 
							    	<option value="footer_left" selected="selected">Footer left</option>
							    	{% else %} 
							    	<option value="footer_left">Footer left</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'footer_right') %} 
							    	<option value="footer_right" selected="selected">Footer right</option>
							    	{% else %} 
							    	<option value="footer_right">Footer right</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'footer_bottom') %} 
							    	<option value="footer_bottom" selected="selected">Footer bottom</option>
							    	{% else %} 
							    	<option value="footer_bottom">Footer bottom</option>
							    	{% endif %} 
							    	{% if (module['position'] == 'bottom') %} 
							    	<option value="bottom" selected="selected">Bottom</option>
							    	{% else %} 
							    	<option value="bottom">Bottom</option>
							    	{% endif %} 
							      </select></td>
							  </tr>
							  <tr>
							    <td>Status:</td>
							    <td><select name="custom_module_module[{{ module_row }}][status]">
							        {% if (module['status']) %} 
							        <option value="1" selected="selected">Enabled</option>
							        <option value="0">Disabled</option>
							        {% else %} 
							        <option value="1">Enabled</option>
							        <option value="0" selected="selected">Disabled</option>
							        {% endif %} 
							      </select></td>
							  </tr>
							  <tr>
							    <td>Sort Order:</td>
							    <td><input type="text" name="custom_module_module[{{ module_row }}][sort_order]" value="{{ module['sort_order'] }}" size="3" /></td>
							  </tr>
							</table>
						</div>
						{% set module_row = module_row + 1 %} 
						{% endfor %} 
					</div>
					
					<!-- Buttons -->
					<div class="buttons"><input type="submit" name="button-save" class="button-save" value=""></div>
				</div>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript"><!--
$('.main-tabs a').tabs();
//--></script> 

<script type="text/javascript"><!--
{% set module_row = 1 %} 
{% for module in modules %} 
$('#language-{{ module_row }} a').tabs();
{% set module_row = module_row + 1 %} 
{% endfor %} 
//--></script> 

<script type="text/javascript"><!--
{% set module_row = 1 %} 
{% for module in modules %} 
{% set module_row = module_row + 1 %} 
{% endfor %} 
//--></script> 

<script type="text/javascript">
$(document).ready(function() {
	
	$('#custom_module').on('change', 'select.select-type', function () {
		var id_module = $(this).attr("id");
		$("#" + id_module +" option:selected").each(function() {
			if($(this).val() == 1) {
				$(".html" + id_module + "").hide();
				$(".block" + id_module + "").show();
			} else {
				$(".html" + id_module + "").show();
				$(".block" + id_module + "").hide();
			}
		});
	});
	
});
</script>

<script type="text/javascript"><!--
var module_row = {{ module_row }};

function addModule() {	
	html  = '<div id="tab-module-' + module_row + '" class="tab-content">';

		html += '	<table class="form" style="margin-bottom:10px">';
		html += '		<tr>';
		html += '			<td style="border:none;padding-top:7px">Type:</td>';
		html += '			<td style="border:none;padding-top:7px">';
		html += '				<select name="custom_module_module[' + module_row + '][type]" class="select-type" id="' + module_row + '">';
		html += '					<option value="1" selected="selected">Block</option>';
		html += '					<option value="2">HTML</option>';
		html += '				</select>';
		html += '			</td>';
		html += '		</tr>';
		html += '   </table>';
		
		html += '  <div id="language-' + module_row + '" class="htabs">';
	    {% for language in languages %} 
	    html += '    <a href="#tab-language-'+ module_row + '-{{ language['language_id'] }}"><img src="language/{{ language['code'] }}/{{ language['code'] }}.png" title="{{ language['name'] }}" /> {{ language['name'] }}</a>';
	    {% endfor %} 
		html += '  </div>';
	
		{% for language in languages %} 
		html += '    <div id="tab-language-'+ module_row + '-{{ language['language_id'] }}">';
		
		html += '	 <div class="block' + module_row + '">';
		html += '	   <table class="form">';
		html += '			<tr>';
		html += '				<td>Block heading:</td>';
		html += '				<td><input type="text" value="" name="custom_module_module[' + module_row + '][block_heading][{{ language['language_id'] }}]" style="width:250px"></td>';
		html += '			</tr>';
		html += '			<tr>';
		html += '				<td>Block content:</td>';
		html += '				<td><textarea name="custom_module_module[' + module_row + '][block_content][{{ language['language_id'] }}]" id="block-content-' + module_row + '-{{ language['language_id'] }}"></textarea></td>';
		html += '			</tr>';
		html += '	   </table>';
		html += '	 </div>';
		
		html += '	 <div class="html' + module_row + '" style="display:none">';
		html += '      <table class="form">';
		html += '        <tr>';
		html += '          <td>HTML:</td>';
		html += '          <td><textarea name="custom_module_module[' + module_row + '][html][{{ language['language_id'] }}]" class="html"></textarea></td>';
		html += '        </tr>';
		html += '      </table>';
		html += '	  </div>';
		
		html += '    </div>';
		{% endfor %} 
	
		html += '  <table class="form">';
		html += '    <tr>';
		html += '      <td>Layout:</td>';
		html += '      <td><select name="custom_module_module[' + module_row + '][layout_id]">';
		html += '           <option value="99999">All pages</option>';
		
		          {% for store in stores %} 
		html += '           		<option value="99999{{ store['store_id'] }}">All pages - Store {{ store['name'] }}</option>';
		          {% endfor %} 
		          
		{% for layout in layouts %} 
		html += '           <option value="{{ layout['layout_id'] }}">{{ layout['name']|e('html') }}</option>';
		{% endfor %} 
		html += '      </select></td>';
		html += '    </tr>';
		html += '    <tr>';
		html += '      <td>Position:</td>';
		html += '      <td><select name="custom_module_module[' + module_row + '][position]">';
		html += '       		<option value="header_notice">Header notice</option>';
		html += '       		<option value="top_block">Top block</option>';
		html += '       		<option value="menu">Menu</option>';
		html += '				<option value="slideshow">Slideshow</option>';
		html += '				<option value="preface_left">Preface left</option>';
		html += '				<option value="preface_right">Preface right</option>';
		html += '				<option value="preface_fullwidth">Preface fullwidth</option>';
		html += '				<option value="column_left">Column left</option>';
		html += '				<option value="content_big_column">Content big column</option>';
		html += '				<option value="content_top">Content top</option>';
		html += '				<option value="column_right">Column right</option>';
		html += '				<option value="content_bottom">Content bottom</option>';
		html += '				<option value="customfooter_top">CustomFooter Top</option>';
		html += '				<option value="customfooter_bottom">CustomFooter Bottom</option>';
		html += '				<option value="footer_top">Footer top</option>';
		html += '				<option value="footer_left">Footer left</option>';
		html += '				<option value="footer_right">Footer right</option>';
		html += '				<option value="footer_bottom">Footer bottom</option>';
		html += '				<option value="bottom">Bottom</option>';
		html += '      </select></td>';
		html += '    </tr>';
		html += '    <tr>';
		html += '      <td>Status:</td>';
		html += '      <td><select name="custom_module_module[' + module_row + '][status]">';
		html += '        <option value="1">Enabled</option>';
		html += '        <option value="0">Disabled</option>';
		html += '      </select></td>';
		html += '    </tr>';
		html += '    <tr>';
		html += '      <td>Sort Order:</td>';
		html += '      <td><input type="text" name="custom_module_module[' + module_row + '][sort_order]" value="" size="3" /></td>';
		html += '    </tr>';
		html += '  </table>'; 
	html += '</div>';
	
	$('.tabs').append(html);
	
	$('#language-' + module_row + ' a').tabs();

	$('#module-add').before('<a href="#tab-module-' + module_row + '" id="module-' + module_row + '">Module ' + module_row + ' &nbsp;<img src="view/image/module_template/delete-slider.png" alt="" onclick="$(\'.vtabs a:first\').trigger(\'click\'); $(\'#module-' + module_row + '\').remove(); $(\'#tab-module-' + module_row + '\').remove(); return false;" /></a>');
	
	$('.main-tabs a').tabs();
	
	$('#module-' + module_row).trigger('click');
	
	{% for language in languages %} 
		$('#html-' + module_row + '-{{ language['language_id'] }}, #block-content-{{ module_row }}-{{ language['language_id'] }}').summernote({
			height: 300
		});
	{% endfor %} 
	
	module_row++;
}
//--></script> 
{{ footer }}